package com.waterworld.watch.home.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.waterworld.watch.R;
import com.waterworld.watch.common.bean.RemotePhotoBean;
import com.waterworld.watch.common.net.UrlContants;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by nhuan
 * Time:2019/3/16.
 */

public class RemotePhotoAdapter extends RecyclerView.Adapter<RemotePhotoAdapter.MyHolder> {

    private Context mContext;
    private List<RemotePhotoBean> mList;

    public RemotePhotoAdapter(Context context,List<RemotePhotoBean> list) {
        this.mContext = context;
        this.mList = list;
    }

    @NonNull
    @Override
    public MyHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_remote_photo,viewGroup,false);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyHolder myHolder, int i) {
        Glide.with(mContext).load(UrlContants.FILE_URL + "resources/watch/"+mList.get(i).getPhoto()).into(myHolder.iv_remote_photo);
    }

    @Override
    public int getItemCount() {
        return mList == null ? 0 : mList.size();
    }

    class MyHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_remote_photo)
        ImageView iv_remote_photo;

        public MyHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
